<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<jsp:include page="../admin.jsp"></jsp:include>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>编码管理</title>
<jsp:include page="../../../inc/js.jsp"></jsp:include>
<jsp:include page="../../../inc/css.jsp"></jsp:include>
<script type="text/javascript">
	function movePage(pageNo) {
		window.location = '?pageNo=' + pageNo + param();
	}
	function param(){
		return '&name='+$("#name").val()+'&code='+$("#code").val()+'&pCode='+$("#pCode").val()+'&type='+$("#type").val();
	}
	$(function() {
		$("#search").button().click(function() {
			movePage(1);
		});
		$("#add").button().click(function() {
			location.href="codeEdit.do";
		});
	});
	function del(id){
		if(confirm('确认删除？')){
			$.ajax( {
				type : "get",
				url : "deleteCode.do?"+Math.random(),
				data : {
					id : id
				},
				dataType:'json',
				error : function() {
					alert("加载错误");
				},
				success : function(data) {
					if(data.success){
						clearSelect();
						alert('操作成功！');
						location='?';
					}else alert('操作失败！\r\n'+data.err);
				}
			});
		}
	}
</script>
</head>
<body><jsp:include page="functionPath.jsp">
	<jsp:param value="${url}" name="url"/>
</jsp:include>
<table class="list" cellpadding="0" cellspacing="1">
	<thead>
		<tr>
			<td class="search" colspan="6">
				编码：<input type="text" name="code" id="code" value="${param.code}" />
				上级编码：<input type="text" name="pCode" id="pCode" value="${param.pCode}" />
				名称：<input type="text" name="name" id="name" value="${param.name}" />
				分类编码：<input type="text" name="type" id="type" value="${param.type}" />
				<button id="search">查询</button>
				<button id="add">添加</button>
			</td>
		</tr>
		<tr>
			<td>编码</td>
			<td>上级编码</td>
			<td>名称</td>
			<td>分类编码</td>
			<td>启用</td>
			<td>操作</td>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="e" items="${o.dataList}" varStatus="s">
			<tr>
				<td>${e.code}</td>
				<td>${e.pCode }</td>
				<td>${e.name}</td>
				<td align="center">${e.type }</td>
				<td align="center"><c:if test="${e.enabled=='1'}">是</c:if><c:if test="${e.enabled!='1'}">否</c:if></td>
				<td align="center"><a href="javascript:location.href='codeEdit.do?id=${e.id}'"><img src="lib/images/write.png"/></a>
					<a href="javascript:del(${e.id})"><img src="lib/images/close.gif"/></a></td>
			</tr>
		</c:forEach>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="6">${o.pageNav }</td>
		</tr>
	</tfoot>
</table>
</body>
</html>